测试链接：https://leetcode.cn/problems/move-zeroes/description/

class Solution {
public:
    void swap(int& left, int& right) {
        int temp = left;
        left = right;
        right = temp;
    }

    void moveZeroes(vector<int>& nums) {
        if (nums.size() < 2)
            return;

        int n = nums.size();
        int left = 0;
        int right = 0;

        while (right < n) {
            if (nums[right] != 0) {
                swap(nums[left], nums[right]);
                left++;
            }
            right++;
        }
    }
};